{extend name="common:base" /}
{block name="css"}
<!--pickers css-->
<link rel="stylesheet" type="text/css" href="__JS__/bootstrap-datepicker/css/datepicker-custom.css" />
<link rel="stylesheet" type="text/css" href="__JS__/bootstrap-timepicker/css/timepicker.css" />
<link rel="stylesheet" type="text/css" href="__JS__/bootstrap-colorpicker/css/colorpicker.css" />
<link rel="stylesheet" type="text/css" href="__JS__/bootstrap-daterangepicker/daterangepicker-bs3.css" />
<link rel="stylesheet" type="text/css" href="__JS__/bootstrap-datetimepicker/css/datetimepicker-custom.css" />
<style>
    .aaa:hover{
        transform: scale(1.5);
    }
    </style>
{/block}
{block name="main"}
<!--body wrapper start-->
<div class="wrapper">
    <div class="pull-left">
        <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
    </div>
    <div class="row">
        <div class="col-md-12">
            <!--breadcrumbs start -->
            <ul class="breadcrumb panel">
                <li><a href="{:url('Index/index')}"><i class="fa fa-home"></i> 控制台</a></li>
                <li><a href="{:url('index')}">会员管理</a></li>
                <li class="active">机器人信息</li>
            </ul>
            <!--breadcrumbs end -->
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel">
                <header class="panel-heading col-xs-12">

                    <form class="form-inline" action="{:url()}">
                        <div class="form-group">
                                <select name="cate" class="form-control ">
                                    <option value="" >选择彩种</option>
                                    {foreach $cates as $v}
                                    <option value="{$v.id}"  {if (isset($cate) && $cate eq $v.id )}selected="selected"{/if}>{$v.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                        <a href="#"  class="btn btn-success ajax-get" onclick="recharge();"title="添加机器人">添加机器人</a>
                    </form>
                </header>

                <div class="panel-body">
                    <form class="ids" action="" method="post">
                        <table class="table">
                            <thead>
                            <tr>
                                <!--<th><input class="check-all" type="checkbox"/></th>-->
                                <th>机器人ID</th>
                                <th>头像</th>
                                <th>昵称</th>
                                <th>彩种</th>
                                <th>房间</th>
                                <th>状态</th>
                                <th>最低投注</th>
                                <th>最高投注</th>
                                <th>间隔时间</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name='list' id='v'}
                            <tr>
                                <!--<td><input class="ids" type="checkbox" value="{$v.id}" name="ids[]"/></td>-->
                                <td>{$v.id}</td>
                                <td><img style="border-radius: 50%" width="50" src="URL_IMG{$v.logo}" class="aaa"></td>
                                <td>{$v.nickname}</td>
                                <td>{$v.cate_name}</td>
                                <td>{$v.hall_name}</td>
                                <td>{if $v.status==1}开启{else/}关闭{/if}</td>
                                <td>{$v.down}</td>
                                <td>{$v.up}</td>
                                <td>{$v.min_time}秒</td>
                                <td>{$v.create_at}</td>
                                <td> <a href="{:url('robot_show',['id'=>$v['id']])}" class="fa fa-edit" title="编辑"></a>
                                      {if $v['status']==0}
                                    <a href="#"   class="btn btn-danger ajax-get" onclick="edit_open('{$v.id}',1)" title="开启">开启</a>
                                    {else/}
                                    <a href="#"   class="btn btn-success ajax-get" onclick="edit_open('{$v.id}',0)" title="关闭">关闭</a>
                                    {/if}
                                </td>
                            {/volist}

                            </tbody>
                        </table>
                    </form>
                </div>
            </section>
            {$page}
        </div>

    </div>
</div>
<!--body wrapper end-->
<!-- Modal -->
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="rechargeModal" class="modal fade">
    <div class="modal-dialog" style="width:400px;">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">添加机器人</h4>
            </div>
            <form class="form-horizontal form-post-addmoney" action="{:url('member/add_robot')}" method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-lg-3 col-sm-3 control-label">机器人昵称</label>
                        <div class="col-lg-8">
                            <input type="text" name="nickname"  class="form-control" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-3 col-sm-3 control-label">头像</label>
                        <div class="col-lg-8">
                              <span class="file_p text-center" id="btn_logo">
                                       <label >点此选择图片</label>
                                       <img height="80px"   id="btn_logo_img" src="__IMG__/add-button.jpg"/><br />
                                       <input type="hidden" name="logo" value=""/>
                              </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-3 col-sm-3 control-label">彩种</label>
                        <div class="col-lg-8">
                            <select name="cate" class="form-control ">
                                <option value="" >选择彩种</option>
                                {foreach $cates as $v}
                                <option value="{$v.id}"  {if (isset($cate) && $cate eq $v.id )}selected="selected"{/if}>{$v.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-3 col-sm-3 control-label">房间</label>
                        <div class="col-lg-8">
                            <select name="hall" class="form-control ">
                            <option value="" >选择房间</option>
                            <option value="1">1号房间</option>
                            <option value="2">2号房间</option>
                            <option value="3">3号房间</option>
                            <option value="4">4号房间</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-3 col-sm-3 control-label">最低投注</label>
                        <div class="col-lg-8">
                            <input type="text" name="down" class="form-control" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-3 col-sm-3 control-label">最高投注</label>
                        <div class="col-lg-8">
                            <input type="text" name="up"  class="form-control" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-lg-3 col-sm-3 control-label">间隔时间（秒）</label>
                        <div class="col-lg-8">
                            <input type="text" name="min_time"  class="form-control" value="">
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id" id="rid" value=""/>
                    <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                    <button class="btn btn-primary " type="submit" target-form="form-post-addmoney">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--body wrapper end-->
{/block}
<!-- modal -->
{block name="js"}
<!--pickers plugins-->
<script type="text/javascript" src="__JS__/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="__JS__/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="__JS__/bootstrap-daterangepicker/moment.min.js"></script>
<script type="text/javascript" src="__JS__/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="__JS__/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
<script type="text/javascript" src="__JS__/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>

<!--pickers initialization-->
<script src="__JS__/pickers-init.js"></script>
<script type="text/javascript">
    function recharge() {
        $('#rechargeModal').modal('show');
    }
    function edit_open(uid,status) {
        $.ajax({
            type: "post",
            url: "{:url('edit_open')}",
            data: {'id':uid,'status':status},
            dataType: "json",
            async: false,
            success: function(data) {
                var info = data.msg;
                alert(info);
                location.reload();
            }
        });
    }
</script>
<script type="text/javascript" src="__JS__/Plupload/plupload.full.min.js"></script>

<script type="text/javascript">

    var ids = new Array("btn_logo");

    $.each(ids,function(i,n){

        var self = this.toString();

        var uploader_avatar = new plupload.Uploader({

            runtimes: 'gears,html5,html4,silverlight,flash', //上传插件初始化选用那种方式的优先级顺序

            browse_button: self, // 上传按钮

            url: "{:url('upload_one')}", //远程上传地址

            flash_swf_url: '__DTSC__/Moxie.swf',//flash文件地址

            silverlight_xap_url: '__DTSC__/Moxie.xap', //silverlight文件地址

            filters: {

                max_file_size: '100mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）

                mime_types: [//允许文件上传类型

                    {title: "files", extensions: "jpg,png,gif,jpeg"}

                ]

            },

            multi_selection: false, //true:ctrl多文件上传, false 单文件上传

            init: {

                FilesAdded: function(up, files) { //文件上传前

                    uploader_avatar.start();

                },

                UploadProgress: function(up, file) { //上传中，显示进度条

                    var percent = file.percent;

                    $("#" + file.id).find('.bar').css({"width": percent + "%"});

                    $("#" + file.id).find(".percent").text(percent + "%");

                },

                FileUploaded: function(up, file, info) { //文件上传成功的时候触发

                    var data = eval("(" + info.response + ")");//解析返回的json数据

                    if(data.status == 1){

                        var img = self+'_img'

                        document.getElementById(img).src = data.pic;

                        document.getElementById(img).width = 200;

                        $('#'+self).find('i').remove();

                        $('#'+self).find('input').val(data.picd);

                    }else{

                        alert(data.error);

                    }

                },

                Error: function(up, err) { //上传出错的时候触发

                    alert(err.message);

                }

            }

        });

        uploader_avatar.init();

    })







</script>
{/block}
